package com.bitoon.basketdudes.web.interceptors;

import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.interceptor.Interceptor;
import java.util.*;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.log4j.Logger;

public class Idioma implements Interceptor {

    private static final String LOCALE_PARAMETER = "locale";
    private Logger log = Logger.getLogger(Idioma.class);

    public void destroy() {
    }

    public void init() {
    }

    public String intercept(ActionInvocation actionInvocation) throws Exception {

        ActionMapping mapping = (ActionMapping)actionInvocation.getInvocationContext().get(ServletActionContext.ACTION_MAPPING);
        Map params = mapping.getParams();
        log.debug("interceptoridioma: begin");
        log.debug("interceptoridioma: params: " + params);

        /*
        Locale locale = (Locale)params.get(LOCALE_PARAMETER);

        log.debug("interceptor idioma, locale: " + locale);

        if (locale != null) {
            ActionContext.getContext().setLocale(locale);
        }
         *
         */

        return actionInvocation.invoke();

    }


}
